<!--机器人参数-->
$(function () {
    function robotArgument() {
        setInterval(robotArgument,1000);
        // console.log("here");
        $.ajax({
            url:"robotWorking",
            success:function (data) {
                // console.log(data);
                $("#deviceTmp").html(data.robotTmpr+"℃");
                $("#restElec").html(data.batteryPct+"%");
                if(data.batteryPct<40){
                    $("#restElecImg").attr("src","img/Humidity/Humidity1.png");
                }else if(data.batteryPct<60){
                    $("#restElecImg").attr("src","img/Humidity/Humidity2.png");
                }else if(data.batteryPct<80){
                    $("#restElecImg").attr("src","img/Humidity/Humidity3.png");
                }else if(data.batteryPct<100){
                    $("#restElecImg").attr("src","img/Humidity/Humidity4.png");
                }else if(data.batteryPct=100){
                    $("#restElecImg").attr("src","img/Humidity/Humidity5.png");
                }
                $("#eleTenVal").html(data.batteryVtage+"V");

                var domPower = document.getElementById("container");
                var myChartPower = echarts.init(domPower);
                var app = {};

                var optionPower;
                optionPower = {
                    title: {
                        left: "center",
                        verticalAlign:"bottom",
                        textStyle: {
                            fontSize: 13,
                            lineHeight: 5,
                            color:"white",
                            align: "right",
                            verticalAlign: "bottom"
                        },
                        show: true,
                        text: "实时功率"
                    },
                    series: [{
                        center: [35,50],
                        type: 'gauge',
                        axisLine: {
                            lineStyle: {
                                width: 4,
                                color: [
                                    [0.3, '#67e0e3'],
                                    [0.7, '#37a2da'],
                                    [1, '#fd666d']
                                ]
                            }
                        },
                        pointer: {
                            itemStyle: {
                                color: 'auto'
                            }
                        },
                        axisTick: {
                            distance: -30,
                            length: 8,
                            lineStyle: {
                                color: '#fff',
                                width: 0
                            }
                        },
                        splitLine: {
                            distance: -30,
                            length: 30,
                            lineStyle: {
                                color: '#fff',
                                width: 0
                            }
                        },
                        axisLabel: {
                            color: 'auto',
                            distance: 0,
                            fontSize: 0
                        },
                        detail: {
                            valueAnimation: true,
                            formatter:'{value}KW',
                            color: 'white',
                            fontSize: 13,
                            offsetCenter: [0,"100%"]
                        },
                        data: [{
                            value:data.realTimePower
                            // value: 70,
                        }]
                    }]
                };
                myChartPower.setOption(optionPower);

                var domSpeed = document.getElementById("container3");
                var myChartSpeed = echarts.init(domSpeed);
                var app = {};

                var optionSpeed;
                optionSpeed = {
                    title: {
                        left: "center",
                        verticalAlign:"bottom",
                        textStyle: {
                            fontSize: 13,
                            lineHeight: 5,
                            color:"white",
                            align: "right",
                            verticalAlign: "bottom"
                        },
                        show: true,
                        text: "运行速度"
                    },
                    series: [{
                        center: [35,50],
                        type: 'gauge',
                        axisLine: {
                            lineStyle: {
                                width: 4,
                                color: [
                                    [0.3, '#67e0e3'],
                                    [0.7, '#37a2da'],
                                    [1, '#fd666d']
                                ]
                            }
                        },
                        pointer: {
                            itemStyle: {
                                color: 'auto'
                            }
                        },
                        axisTick: {
                            distance: -30,
                            length: 8,
                            lineStyle: {
                                color: '#fff',
                                width: 0
                            }
                        },
                        splitLine: {
                            distance: -30,
                            length: 30,
                            lineStyle: {
                                color: '#fff',
                                width: 0
                            }
                        },
                        axisLabel: {
                            color: 'auto',
                            distance: 0,
                            fontSize: 0
                        },
                        detail: {
                            valueAnimation: true,
                            formatter:'{value}km/s',
                            color: 'white',
                            fontSize: 13,
                            offsetCenter: [0,"100%"],
                        },
                        data: [{
                            value: data.robotSpd,
                        }]
                    }]
                };
                myChartSpeed.setOption(optionSpeed);
            }
        });
    }
    robotArgument();
})